//
//  XMWebBottomView.m
//  XMWebTool
//
//  Created by ext.zhangmingwei8 on 2023/12/7.
//

#import "XMWebBottomView.h"
#import "XMSizeMacro.h"
#import "UIView+XMFrame.h"
#import "UIColor+XMTool.h"

@implementation XMWebBottomView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    
    self.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:self.favoriteBtn];
    [self addSubview:self.backBtn];
    [self addSubview:self.reloadBtn];
    [self addSubview:self.closeBtn];

    CGFloat btnW = kScreenWidth_XM/4.0;
    CGFloat btnH = 50;

    self.favoriteBtn.frame = CGRectMake(0, 0, btnW, btnH);
    self.backBtn.frame = CGRectMake(self.favoriteBtn.right, 0, btnW, btnH);
    self.reloadBtn.frame = CGRectMake(self.backBtn.right, 0, btnW, btnH);
    self.closeBtn.frame = CGRectMake(self.reloadBtn.right, 0, btnW, btnH);
    
    UIView *lineV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth_XM, 0.6)];
    lineV.backgroundColor = [UIColor getBlackColor_1];
    lineV.alpha = 0.2;
    [self addSubview:lineV];

    return self;
}

- (UIButton *)backBtn {
    if (!_backBtn) {
        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _backBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
        [_backBtn setTitleColor:[UIColor getGreenColor_XM] forState:UIControlStateNormal];
//        [_backBtn setTitle:@"后退" forState:UIControlStateNormal];
        [_backBtn setImage:[UIImage imageNamed:@"icon_left"] forState:UIControlStateNormal];
    }
    return _backBtn;
}

- (UIButton *)reloadBtn {
    if (!_reloadBtn) {
        _reloadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _reloadBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
        [_reloadBtn setTitleColor:[UIColor getGreenColor_XM] forState:UIControlStateNormal];
//        [_reloadBtn setTitle:@"刷新" forState:UIControlStateNormal];
        [_reloadBtn setImage:[UIImage imageNamed:@"icon_refresh"] forState:UIControlStateNormal];
    }
    return _reloadBtn;
}

- (UIButton *)closeBtn {
    if (!_closeBtn) {
        _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _closeBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
        [_closeBtn setTitleColor:[UIColor getGreenColor_XM] forState:UIControlStateNormal];
//        [_closeBtn setTitle:@"关闭" forState:UIControlStateNormal];
        [_closeBtn setImage:[UIImage imageNamed:@"icon_close"] forState:UIControlStateNormal];
    }
    return _closeBtn;
}

- (UIButton *)favoriteBtn {
    if (!_favoriteBtn) {
        _favoriteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _favoriteBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
        [_favoriteBtn setTitleColor:[UIColor getGreenColor_XM] forState:UIControlStateNormal];
//        [_favoriteBtn setTitle:@"复制" forState:UIControlStateNormal];
        [_favoriteBtn setImage:[UIImage imageNamed:@"icon_copy"] forState:UIControlStateNormal];
    }
    return _favoriteBtn;
}

@end
